package edu.spec.dengyan.week08.class01.book.unit4.topic03;

/**
 * Author       : Dengyan
 * Date         : 2018/10/11 23:19
 * Description  : “Student”类
 */
public class Student extends Person{
    private String no;
    private double scoreOfEn;
    private double scoreOfMath;
    private double scoreOfCh;

    public Student(String no, double scoreOfEn, double scoreOfMath, double scoreOfCh) {
        this.no=no;
        this.scoreOfEn=scoreOfEn;
        this.scoreOfMath=scoreOfMath;
        this.scoreOfCh=scoreOfCh;
    }

    public String getNo() {
        return no;
    }

    public double getScoreOfEn() {
        return scoreOfEn;
    }

    public double getScoreOfMath() {
        return scoreOfMath;
    }

    public double getScoreOfCh() {
        return scoreOfCh;
    }
    public double aver(){
        return (getScoreOfEn()+getScoreOfMath()+getScoreOfCh())/3;
    }
    public double max(){
        double data[]={getScoreOfEn(),getScoreOfMath(),getScoreOfCh()};
        java.util.Arrays.sort(data);//数字从小到大排序
        return data[2];
    }
    public double min(){
        double f;
        if(getScoreOfEn()>getScoreOfMath() && getScoreOfMath()>getScoreOfCh())
        {
            f=getScoreOfCh();
        }
        else if(getScoreOfEn()>getScoreOfCh() && getScoreOfCh()>getScoreOfMath())
        {
            f=getScoreOfMath();
        }
        else if(getScoreOfMath()>getScoreOfCh() && getScoreOfCh()>getScoreOfEn())
        {
            f=getScoreOfEn();
        }
        else if(getScoreOfCh()>getScoreOfEn() && getScoreOfEn()>getScoreOfMath())
        {
            f=getScoreOfMath();
        }
        else
        {
            f=getScoreOfEn();
        }
        return f;
    }

    @Override
    public  String toString() {
        return this.no+" "+" "+this.aver()+" "+this.max()+" "+this.min();
    }

    public static void main(String[] args) {
        Person s=new Student("17102",60.5,85.2,89.5);
        Person l=new Person("娜娜",'女',20);
        System.out.println(l.toString());
        System.out.println(s.toString());
    }
}
